package view.backend;

import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.*;
import model.ProductFamily;
import view.generaldesign.DesignLayout;

/**
 *
 * @author Sonny Sandberg
 */
public class AdminProductFamilyPanel extends JPanel
{
    public AdminProductFamilyPanel(final AdminProductFamily view, final ProductFamily thisProductFamily)
    {
        setLayout(null);
        setSize(new Dimension(260, 50));
        setBorder(DesignLayout.T_FIELD_RED);
        
        JLabel lblId = new JLabel("<html><b>Varegruppenummer:</b> "+thisProductFamily.getId()+"</html>");
        lblId.setBounds(10, 5, 250, 18);
        lblId.setFont(DesignLayout.STANDARD);
        JLabel lblName = new JLabel("<html><b>Navn:</b> "+thisProductFamily.getName()+"</html>");
        lblName.setBounds(10, 25, 250, 18);
        lblName.setFont(DesignLayout.STANDARD);
        
        add(lblId);
        add(lblName);
        
        MouseAdapter 
                    mouseEntered,
                    mouseExited;
        
        mouseEntered =
                (
                    new MouseAdapter()
                    {
                        public void mouseEntered(MouseEvent evt)
                        {
                            setCursor(new Cursor(Cursor.HAND_CURSOR));
                        }
                    }
                );
        
        mouseExited =
                (
                    new MouseAdapter()
                    {
                        public void mouseExited(MouseEvent evt)
                        {
                            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                        }
                    }
                );
        
        MouseAdapter mouseReleased;
        mouseReleased =
                (
                    new MouseAdapter()
                    {
                        public void mouseReleased(MouseEvent evt)
                        {
                            view.setProductFamilyObject(thisProductFamily);
                        }
                    }
                );
        
        this.addMouseListener(mouseReleased);
        this.addMouseListener(mouseEntered);
        this.addMouseListener(mouseExited);
    }
}